/*
 * XQueryEditorFactory.java
 */

package xq.ide;

import java.io.File;
import java.io.IOException;
import xq.swing.Editor;
import xq.swing.EditorFactory;

/**
 *
 * @author ThorntonRP
 */
public class XQueryEditorFactory implements EditorFactory {

	public boolean acceptsContentType(String contentType) {
		return "text/xquery".equals(contentType);
	}

	public Editor createEditor(String contentType) {
		if (acceptsContentType(contentType)) {
			Editor editor = new XQueryEditor();
			editor.setName("New XQuery");
			return editor;
		} else {
			throw new IllegalArgumentException("Unsupported content type: " + contentType);
		}
	}

	public Editor createEditor(String contentType, File f) throws IOException {
		if (acceptsContentType(contentType)) {
			Editor editor = new XQueryEditor(f);
			editor.setName(f.getName());
			return editor;
		} else {
			throw new IllegalArgumentException("Unsupported content type: " + contentType);
		}
	}
}
